package portal.conf.entity;

import portal.common.MyStringUtils;

public class GPUEntity extends BaseConf{
	private static int MAX_INDEX=-1;
	//对应Node 中 gpuIdentify
	String res;
	//对应Node 中 gpuVersion
	String name;
	//对应Node 中 gpuDetail
	String info;
	int index;
	public GPUEntity(){}
	//public GPUEntity(){}
	public GPUEntity(String res,String name,String info){
		this.res=res;
		this.name=name;
		this.info=info;
		this.index=MAX_INDEX+1;
	}
	public String getIdentify(){
		return getRes();
	}
	public String getRes() {
		return res==null?"":res;
	}
	public String getVersion(){
		return getName();
	}
	public String getName() {
		return name;
	}
	public String getDetail(){
		return info;
	}
	public String getInfo() {
		return info;
	}
	public int getIndex() {
		return index;
	}	
	public void checkIndex(){
		if(index<0)
			index=0;
		if(MAX_INDEX>=0)
			index=MAX_INDEX+1;
	}
	public GPUEntity setValue(String val){
		val =MyStringUtils.strictSpace(val);
		int iRes=-1,iName=-1,iInfo=-1;
		iRes=val.indexOf("DB_Res[");
		iName=val.indexOf("DB_Name[");
		iInfo=val.indexOf("DB_Info[");
		if(iRes>=0 && iName>0){
			res=val.substring(val.indexOf("\"")+1, iName -2);
		}
		if(iName>0 && iInfo>0){
			name=val.substring(val.indexOf("\"", iName)+1,iInfo-2);
		}
		if(iInfo>0){
			info=val.substring(val.indexOf("\"", iInfo)+1,val.length()-1);
		}
		//System.out.println(val.substring(val.indexOf("[")+1,val.indexOf("]")));
		index=Integer.valueOf(val.substring(val.indexOf("[")+1,val.indexOf("]")));
		if(index >= MAX_INDEX)
			MAX_INDEX=index;
		return this;
	}
	@Override
	public String toString(){
		return "    DB_Res["+index+"]=\""+res+"\"           DB_Name["+index+"]=\""+name+"\"          DB_Info["+index+"]=\""+info+"\"";
	}
	public void setRes(String res) {
		this.res = res;
	}
	public void setName(String name) {
		this.name = name;
	}
	public void setInfo(String info) {
		this.info = info;
	}
	@Override
	public String getKey() {
		// TODO Auto-generated method stub
		return getName();
	}
	
}
